﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using FinosLibrary;
namespace BattleShip {
    /// <summary>
    /// Interaction logic for PropertyPage.xaml
    /// </summary>
  
    public partial class PropertyPage : UserControl {
        private PCTable pcTable= new object().GetInstance<PCTable>();
        public PropertyPage() {
            InitializeComponent();
            tabItem1.DataContext = pcTable;
        }

        private void Button_Click(object sender, RoutedEventArgs e) {
            if (pages.SelectedIndex > 0)
                pages.SelectedIndex--;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e) {
            if (pages.SelectedIndex < pages.Items.Count - 1)
                pages.SelectedIndex++;
        }

        private void TextBox_KeyDown(object sender, KeyEventArgs e) {
            if (e.Key == Key.Enter) {
                (sender as TextBox).GetBindingExpression(TextBox.TextProperty).UpdateSource();
            }
        }

        private void Button_Click_2(object sender, RoutedEventArgs e) {
            pcTable.database.SubmitChanges();
        }

        private void Button_Click_4(object sender, RoutedEventArgs e) {
            pcTable.database.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, pcTable.Table);
        }
    }
}
